import { Route, Redirect } from 'react-router-dom'
import { getToken } from 'utils/storage'
// 鉴权路由
// ...rest 剩余参数  {...rest}
export default function AuthRoute({ path, component: Component, ...rest }) {
  // console.log(rest)
  return (
    <Route
      {...rest}
      path={path}
      render={(props) => {
        const token = getToken()
        if (token) {
          return <Component {...props} />
        } else {
          return <Redirect to={{ pathname: '/login', state: { form: props.location.pathname, aa: '1111' } }} />
        }
      }}
    ></Route>
  )
}
